package com.kanshu.basictest.ui.base;

import android.widget.AdapterView;

import com.kanshu.basictest.R;
import com.kanshu.basictest.model.menu.MenuItem;
import com.kanshu.basictest.widget.adapter.menu.RecyclerMenuAdapter;

import java.util.List;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public abstract class BaseRecyclerMenuActivity<T extends MenuItem> extends BaseToolbarActivity implements RecyclerMenuAdapter.OnItemClickedListener<T> {

    @BindView(R.id.rv_menu)
    RecyclerView rvMenu;

    @Override
    protected int provideLayoutResId() {
        return R.layout.activity_recycler_view;
    }


    @Override
    protected void init() {
        super.init();
        initView();
    }

    private void initView() {
        List<T> menuItems = provideMenuData();
        RecyclerMenuAdapter<T> listMenuAdapter = new RecyclerMenuAdapter<>(menuItems);
        listMenuAdapter.setOnItemClickedListener(this);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
        rvMenu.setLayoutManager(layoutManager);
        rvMenu.setAdapter(listMenuAdapter);
    }

    protected abstract List<T> provideMenuData();


}
